﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using YArchitech.LIB;
using Microsoft.CSharp.RuntimeBinder;
using Microsoft.Office.Interop.Excel;


namespace YArchitech.Temp
{
	internal class HYDuctSystemExcelBook
	{
		public HYDuctSystem DuctSystem
		{
			get
			{
				return this.m_DuctSystem;
			}
		}

		public string ErrorString { get; set; }

		public HYDuctSystemExcelBook(HYDuctSystem ductSystem, BackgroundWorker bkWorker = null)
		{
			this.m_DuctSystem = ductSystem;
			this.m_BkWorker = bkWorker;
			this.GridColumns = ColumnInfo.GetColumnInfo();
			this.ColumnCount = this.GridColumns.Count;
		}

		private void MergeCells(int rowIndex, int startCol, int endCol)
		{
			this.sheetSystemInfo.get_Range(this.ToCellPosition(rowIndex, startCol), this.ToCellPosition(rowIndex, endCol)).MergeCells = true;
		}

		private void MergeRowCells(int rowIndex, int colNum, int endRow)
		{
			this.sheetCoefficient.get_Range(this.ToCellPosition(rowIndex, colNum), this.ToCellPosition(endRow, colNum)).MergeCells = true;
		}

		private void MergeCellsCoeff(int rowIndex, int startCol, int endCol)
		{
			this.sheetCoefficient.get_Range(this.ToCellPosition(rowIndex, startCol), this.ToCellPosition(rowIndex, endCol)).MergeCells = true;
		}

		private string ToCellPosition(int rowIndex, int columnIndex)
		{
			return string.Format("{0}{1}", this.GetColumnName(columnIndex), rowIndex);
		}

		private string GetColumnName(int columnIndex)
		{
			columnIndex--;
			if (columnIndex < 26)
			{
				char c = (char)(columnIndex + 65);
				return string.Format("{0}", c);
			}
			if (columnIndex > 51)
			{
				throw new Exception("列数太多了，暂时不支持");
			}
			columnIndex -= 26;
			return string.Format("{0}{1}", "A", (char)(columnIndex + 65));
		}

        public void SetColumnWidth_Dongyi(int columnIndex, int width)
        {
            //Microsoft.Office.Interop.Excel.Application xlsApp = new Microsoft.Office.Interop.Excel.Application();

            //string strExcelPathName = AppDomain.CurrentDomain.BaseDirectory + "excelSheetName.xls";
            //Microsoft.Office.Interop.Excel.Workbook workBook = xlsApp.Workbooks.Open(strExcelPathName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            //    Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

            //读取已打开的Excel
            Microsoft.Office.Interop.Excel.Worksheet workSheet1 = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["SheetName1"];

            Microsoft.Office.Interop.Excel.Worksheet workSheet2 = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["SheetName2"];
 
             //添加一个workSheet
            Worksheet workSheet = (Worksheet)workbook.Worksheets.Add(System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);

            //RowHeight   "1:1"表示第一行, "1:2"表示,第一行和第二行 
             ((Microsoft.Office.Interop.Excel.Range)workSheet.Rows["1:1", System.Type.Missing]).RowHeight = 100;

            //ColumnWidth "A:B"表示第一列和第二列, "A:A"表示第一列
             ((Microsoft.Office.Interop.Excel.Range)workSheet.Columns["A:B", System.Type.Missing]).ColumnWidth = 10;
        }

		public void SetColumnWidth(int columnIndex, int width)
		{
			string columnName = this.GetColumnName(columnIndex);
            //if (HYDuctSystemExcelBook.<>o__23.<>p__0 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__23.<>p__0 = CallSite<Func<CallSite, object, Range>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Range), typeof(HYDuctSystemExcelBook)));
            //}
            //HYDuctSystemExcelBook.<>o__23.<>p__0.Target(HYDuctSystemExcelBook.<>o__23.<>p__0, this.sheetSystemInfo.Columns[columnName + ":" + columnName, Type.Missing]).ColumnWidth = width;
		}

		public void ColumnWidthAutoFit(int columnIndex)
		{
			string columnName = this.GetColumnName(columnIndex);
            //if (HYDuctSystemExcelBook.<>o__24.<>p__0 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__24.<>p__0 = CallSite<Func<CallSite, object, Range>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Range), typeof(HYDuctSystemExcelBook)));
            //}
            //HYDuctSystemExcelBook.<>o__24.<>p__0.Target(HYDuctSystemExcelBook.<>o__24.<>p__0, this.sheetSystemInfo.Columns[columnName + ":" + columnName, Type.Missing]).EntireColumn.AutoFit();
		}

		public void SetColumnWidthCoeff(int columnIndex, int width)
		{
			string columnName = this.GetColumnName(columnIndex);
            //if (HYDuctSystemExcelBook.<>o__25.<>p__0 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__25.<>p__0 = CallSite<Func<CallSite, object, Range>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Range), typeof(HYDuctSystemExcelBook)));
            //}
            //HYDuctSystemExcelBook.<>o__25.<>p__0.Target(HYDuctSystemExcelBook.<>o__25.<>p__0, this.sheetCoefficient.Columns[columnName + ":" + columnName, Type.Missing]).ColumnWidth = width;
		}

		public void ColumnWidthAutoFitCoeff(int columnIndex)
		{
			string columnName = this.GetColumnName(columnIndex);
            //if (HYDuctSystemExcelBook.<>o__26.<>p__0 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__26.<>p__0 = CallSite<Func<CallSite, object, Range>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Range), typeof(HYDuctSystemExcelBook)));
            //}
            //HYDuctSystemExcelBook.<>o__26.<>p__0.Target(HYDuctSystemExcelBook.<>o__26.<>p__0, this.sheetCoefficient.Columns[columnName + ":" + columnName, Type.Missing]).EntireColumn.AutoFit();
		}

		private void WriteTextCoeff(ref int rowIndex, int startColumnIndex, int endColumnIndex, string text, bool HorizontalCenter = false)
		{
			this.sheetCoefficient.Cells[rowIndex, startColumnIndex] = text;
            Microsoft.Office.Interop.Excel.Range range = this.sheetSystemInfo.get_Range(this.ToCellPosition(rowIndex, startColumnIndex), this.ToCellPosition(rowIndex, endColumnIndex));
			range.MergeCells = true;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			if (HorizontalCenter)
			{
				range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			}
			else
			{
				range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
			}
			rowIndex++;
		}

		private void WriteText(ref int rowIndex, int startColumnIndex, int endColumnIndex, string text, bool HorizontalCenter = false)
		{
			this.sheetSystemInfo.Cells[rowIndex, startColumnIndex] = text;
            Microsoft.Office.Interop.Excel.Range range = this.sheetSystemInfo.get_Range(this.ToCellPosition(rowIndex, startColumnIndex), this.ToCellPosition(rowIndex, endColumnIndex));
			range.MergeCells = true;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			if (HorizontalCenter)
			{
				range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			}
			else
			{
				range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
			}
			rowIndex++;
		}

		private void WriteRowText(ref int rowIndex, int startColumnIndex, string text, bool HorizontalCenter = false)
		{
			this.sheetSystemInfo.Cells[rowIndex, startColumnIndex] = text;
            Microsoft.Office.Interop.Excel.Range range = this.sheetCoefficient.get_Range(this.ToCellPosition(rowIndex, startColumnIndex), this.ToCellPosition(rowIndex + 1, startColumnIndex));
			range.MergeCells = true;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			if (HorizontalCenter)
			{
				range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			}
			else
			{
				range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
			}
			rowIndex++;
		}

		private void AddBorder(int startRow, int startCol, int endRow, int endCol)
		{
            Microsoft.Office.Interop.Excel.Range range = this.sheetSystemInfo.get_Range(this.ToCellPosition(startRow, startCol), this.ToCellPosition(endRow, endCol));
			Borders borders = range.Borders;
			Border border = borders.get_Item(XlBordersIndex.xlEdgeLeft);
			borders.LineStyle = XlLineStyle.xlContinuous;
			borders.Weight = XlBorderWeight.xlThin;
			borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null);
			Border border2 = borders.get_Item(XlBordersIndex.xlEdgeTop);
			borders.LineStyle = XlLineStyle.xlContinuous;
			borders.Weight = XlBorderWeight.xlThin;
			borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null);
			Border border3 = borders.get_Item(XlBordersIndex.xlEdgeBottom);
			borders.LineStyle = XlLineStyle.xlContinuous;
			borders.Weight = XlBorderWeight.xlThin;
			borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null);
			Border border4 = borders.get_Item(XlBordersIndex.xlEdgeRight);
			borders.LineStyle = XlLineStyle.xlContinuous;
			borders.Weight = XlBorderWeight.xlThin;
			borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
			range.BorderAround(XlLineStyle.xlDouble, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null);
		}

		private void AddBorderCoff(int startRow, int startCol, int endRow, int endCol)
		{
            Microsoft.Office.Interop.Excel.Range range = this.sheetCoefficient.get_Range(this.ToCellPosition(startRow, startCol), this.ToCellPosition(endRow, endCol));
			Borders borders = range.Borders;
			Border border = borders.get_Item(XlBordersIndex.xlEdgeLeft);
			borders.LineStyle = XlLineStyle.xlContinuous;
			borders.Weight = XlBorderWeight.xlThin;
			borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null);
			Border border2 = borders.get_Item(XlBordersIndex.xlEdgeTop);
			borders.LineStyle = XlLineStyle.xlContinuous;
			borders.Weight = XlBorderWeight.xlThin;
			borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null);
			Border border3 = borders.get_Item(XlBordersIndex.xlEdgeBottom);
			borders.LineStyle = XlLineStyle.xlContinuous;
			borders.Weight = XlBorderWeight.xlThin;
			borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null);
			Border border4 = borders.get_Item(XlBordersIndex.xlEdgeRight);
			borders.LineStyle = XlLineStyle.xlContinuous;
			borders.Weight = XlBorderWeight.xlThin;
			borders.ColorIndex = XlColorIndex.xlColorIndexAutomatic;
			range.BorderAround(XlLineStyle.xlDouble, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null);
		}

		private void SetBkWorInfo(int step, string messge = "")
		{
			if (this.m_BkWorker == null)
			{
				return;
			}
			this.rate += step;
			if (this.rate > 100)
			{
				this.rate = 100;
			}
			if (string.IsNullOrEmpty(messge))
			{
				this.m_BkWorker.ReportProgress(this.rate);
				return;
			}
			this.m_BkWorker.ReportProgress(this.rate, messge);
		}

		private void StartWorker()
		{
			if (this.m_BkWorker != null)
			{
				this.m_BkWorker.RunWorkerAsync();
			}
		}

		public bool RunExcel()
		{
			this.rate = 0;
			bool result;
			try
			{
				this.SetBkWorInfo(0, "启动Excel...");
				this.excelApplication = (Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
				this.SetBkWorInfo(10, "启动Excel, 创建工作簿...");
				this.workbook = this.excelApplication.Workbooks.Add(1);
				this.workbook.Worksheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                //if (HYDuctSystemExcelBook.<>o__35.<>p__0 == null)
                //{
                //    HYDuctSystemExcelBook.<>o__35.<>p__0 = CallSite<Func<CallSite, object, Worksheet>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Worksheet), typeof(HYDuctSystemExcelBook)));
                //}
                //this.sheetSystemInfo = HYDuctSystemExcelBook.<>o__35.<>p__0.Target(HYDuctSystemExcelBook.<>o__35.<>p__0, this.workbook.Sheets[1]);
                //this.sheetSystemInfo.Name = "风管水力计算书";
                //if (HYDuctSystemExcelBook.<>o__35.<>p__1 == null)
                //{
                //    HYDuctSystemExcelBook.<>o__35.<>p__1 = CallSite<Func<CallSite, object, Worksheet>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(Worksheet), typeof(HYDuctSystemExcelBook)));
                //}
                //this.sheetCoefficient = HYDuctSystemExcelBook.<>o__35.<>p__1.Target(HYDuctSystemExcelBook.<>o__35.<>p__1, this.workbook.Sheets[2]);
				this.sheetCoefficient.Name = "局阻信息";
				int num = 1;
				this.SetBkWorInfo(2, "开始写计算数据...");
				this.SetBkWorInfo(2, "正在输出标题...");
				this.WriteHeader(ref num);
				this.SetBkWorInfo(3, "正在输出计算公式和计算依据...");
				this.WriteBase(ref num);
				this.SetBkWorInfo(7, "正在输出计算计算结果...");
				this.WriteResult(ref num);
				this.SetBkWorInfo(5, "正在输出软件信息...");
				this.WriteText(ref num, 1, this.ColumnCount, "设计软件:" + Product.GetSoftWareName() + Product.GetSoftWareBuildVer(), false);
				this.WriteText(ref num, 1, this.ColumnCount, "计算时间: " + DateTime.Now.ToString(), false);
				this.SetBkWorInfo(5, "正在设置样式体...");
                Microsoft.Office.Interop.Excel.Range range = this.sheetSystemInfo.get_Range(this.ToCellPosition(1, 1), this.ToCellPosition(num - 1, this.ColumnCount));
				range.Font.Name = "微软雅黑";
				range.Font.Size = 12;
				range.NumberFormatLocal = this.NumberFormat;
                Microsoft.Office.Interop.Excel.Range range2 = this.sheetSystemInfo.get_Range(this.ToCellPosition(1, 1), this.ToCellPosition(num - 1, 1));
				range2.Font.Name = "微软雅黑";
				range2.Font.Size = 12;
				range2.NumberFormatLocal = this.NumberMark;
				int num2 = 3;
				this.SetBkWorInfo(7, "正在输出局阻信息...");
				this.WriteResistanceCoefficient(ref num2);
				this.SetBkWorInfo(5, "生成成功...");
				this.excelApplication.Visible = true;
				GC.Collect();
				result = true;
			}
			catch (Exception ex)
			{
				this.ErrorString = ex.Message;
				this.ErrorString = "启动Excel出错，请检查office是否正确安装。\n如有疑问，请与鸿业客服人员联系解决。";
				result = false;
			}
			return result;
		}

		private void WriteHeader(ref int rowIndex)
		{
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "鸿业风系统水力计算书", true);
			rowIndex++;
		}

		private void WriteHeaderCoeff(ref int rowIndex)
		{
			this.WriteTextCoeff(ref rowIndex, 1, 3, "鸿业风系统局阻明细表", true);
			rowIndex++;
		}

		private void WriteBase(ref int rowIndex)
		{
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "一、计算依据\t", false);
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "假定流速法：假定流速法是以风道内空气流速作为控制指标，计算出风道的断面尺寸和压力损失，再按各分支间的压损差值进行调整，以达到平衡。\t", false);
			rowIndex++;
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "二、计算公式\t\t", false);
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "a.管段压力损失 ＝ 沿程阻力损失 ＋ 局部阻力损失 即：ΔP = ΔPm ＋ ΔPj。\t\t", false);
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "b.沿程阻力损失 ΔPm = Δpm×L。\t\t", false);
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "c.局部阻力损失 ΔPj =0.5×ζ×ρ×V^2。\t", false);
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "d.摩擦阻力系数采用柯列勃洛克-怀特公式计算。\t", false);
			rowIndex++;
		}

		private void WriteResult(ref int rowIndex)
		{
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "三、计算结果   \t", false);
			this.SetBkWorInfo(10, "生成管道数据...");
			this.WriteStraightTable(ref rowIndex);
			rowIndex++;
			this.SetBkWorInfo(10, "生成分支数据...");
			this.WriteBranch(ref rowIndex);
		}

		private void WriteBranch(ref int rowIndex)
		{
			this.SetBkWorInfo(1, "生成最不利分支数据...");
			this.WriteText(ref rowIndex, 1, this.ColumnCount, " b." + this.DuctSystem.Name + "最不利分支", false);
			HYBranch maxResistanceBranch = this.DuctSystem.MaxResistanceBranch;
			if (maxResistanceBranch != null)
			{
				string text = string.Concat(new string[]
				{
					this.DuctSystem.Name,
					"最不利分支为 【",
					(maxResistanceBranch.Count == 0) ? "0" : maxResistanceBranch.GetShowIndexString(),
					"】,最不利阻力损失为： ",
					StringTools.DoubleToString(maxResistanceBranch.Resistance, 3),
					" Pa"
				});
				this.WriteText(ref rowIndex, 1, this.ColumnCount, text, false);
			}
			rowIndex++;
			this.SetBkWorInfo(8, "生成分支分析表...");
			int num = 1;
			int num2 = 3;
			int num3 = 7;
			int num4 = 8;
			this.WriteText(ref rowIndex, 1, this.ColumnCount, " c." + this.DuctSystem.Name + "分支分析\t", false);
			this.WriteText(ref rowIndex, 1, num4, " " + this.DuctSystem.Name + "分支分析表\t", true);
			int startRow = rowIndex;
			this.sheetSystemInfo.Cells[rowIndex, num] = "分支名称";
			this.MergeCells(rowIndex, num, num2 - 1);
			this.sheetSystemInfo.Cells[rowIndex, num2] = "分支管段";
			this.MergeCells(rowIndex, num2, num3 - 1);
			this.sheetSystemInfo.Cells[rowIndex, num3] = "分支阻力损失(Pa)";
			this.sheetSystemInfo.Cells[rowIndex, num4] = "分支不平衡率(%)\t";
			rowIndex++;
			this.SetBkWorInfo(2, "生成分支数据...");
			foreach (HYBranch hybranch in this.DuctSystem.Branches)
			{
				this.sheetSystemInfo.Cells[rowIndex, num] = hybranch.ShowName;
				this.MergeCells(rowIndex, num, num2 - 1);
				this.sheetSystemInfo.Cells[rowIndex, num2] = ((hybranch.Count == 0) ? "0" : (hybranch.GetShowIndexString() + "\t"));
				this.MergeCells(rowIndex, num2, num3 - 1);
				this.sheetSystemInfo.Cells[rowIndex, num3] = hybranch.Resistance;
                //if (HYDuctSystemExcelBook.<>o__40.<>p__0 == null)
                //{
                //    HYDuctSystemExcelBook.<>o__40.<>p__0 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
                //    }));
                //}
                //HYDuctSystemExcelBook.<>o__40.<>p__0.Target(HYDuctSystemExcelBook.<>o__40.<>p__0, this.sheetSystemInfo.Cells[rowIndex, num3], this.NumberFormat);
                //this.sheetSystemInfo.Cells[rowIndex, num4] = hybranch.UnbalanceRate;
                //if (HYDuctSystemExcelBook.<>o__40.<>p__1 == null)
                //{
                //    HYDuctSystemExcelBook.<>o__40.<>p__1 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                //    }));
                //}
                //HYDuctSystemExcelBook.<>o__40.<>p__1.Target(HYDuctSystemExcelBook.<>o__40.<>p__1, this.sheetSystemInfo.Cells[rowIndex, num4], "0.00%");
				rowIndex++;
			}
			int endRow = rowIndex - 1;
			this.SetBkWorInfo(5, "添加边框...");
			this.AddBorder(startRow, 1, endRow, num4);
			rowIndex++;
		}

		private void WriteStraightTable(ref int rowIndex)
		{
			this.WriteText(ref rowIndex, 1, this.ColumnCount, "1、" + this.DuctSystem.Name + "(假定流速法)", false);
			this.WriteText(ref rowIndex, 1, this.ColumnCount, " a." + this.DuctSystem.Name + "水力计算表", false);
			string name = this.DuctSystem.Name;
			this.WriteText(ref rowIndex, 1, this.ColumnCount, name, true);
			int startRow = rowIndex;
			int num = 1;
			foreach (ColumnInfo columnInfo in this.GridColumns)
			{
				this.sheetSystemInfo.Cells[rowIndex, num] = columnInfo.HeaderText;
				this.ColumnWidthAutoFit(num);
				num++;
			}
			rowIndex++;
			foreach (HYPipeline hypipeline in this.DuctSystem.Pipelines)
			{
				this.SetBkWorInfo(2, "正在写入" + hypipeline.ShowString);
				this.WriteDuctData(ref rowIndex, hypipeline as HYDuctStraight);
			}
			this.AddBorder(startRow, 1, rowIndex - 1, this.ColumnCount);
		}

		private void WriteDuctData(ref int rowIndex, HYDuctStraight hyduct)
		{
			int num = 1;
			this.sheetSystemInfo.Cells[rowIndex, num] = hyduct.Index;
            //if (HYDuctSystemExcelBook.<>o__42.<>p__0 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__42.<>p__0 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__42.<>p__0.Target(HYDuctSystemExcelBook.<>o__42.<>p__0, this.sheetSystemInfo.Cells[rowIndex, num], "0");
            //num++;
            //this.sheetSystemInfo.Cells[rowIndex, num++] = hyduct.ShapeString;
            //this.sheetSystemInfo.Cells[rowIndex, num] = hyduct.Flow * 3600.0;
            //if (HYDuctSystemExcelBook.<>o__42.<>p__1 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__42.<>p__1 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__42.<>p__1.Target(HYDuctSystemExcelBook.<>o__42.<>p__1, this.sheetSystemInfo.Cells[rowIndex, num], this.NumberFormat);
            //num++;
            //this.sheetSystemInfo.Cells[rowIndex, num++] = hyduct.Width;
            //this.sheetSystemInfo.Cells[rowIndex, num++] = hyduct.Height;
            //this.sheetSystemInfo.Cells[rowIndex, num] = hyduct.Velocity;
            //if (HYDuctSystemExcelBook.<>o__42.<>p__2 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__42.<>p__2 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__42.<>p__2.Target(HYDuctSystemExcelBook.<>o__42.<>p__2, this.sheetSystemInfo.Cells[rowIndex, num], this.NumberFormat);
            //num++;
            //this.sheetSystemInfo.Cells[rowIndex, num] = hyduct.Length;
            //if (HYDuctSystemExcelBook.<>o__42.<>p__3 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__42.<>p__3 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__42.<>p__3.Target(HYDuctSystemExcelBook.<>o__42.<>p__3, this.sheetSystemInfo.Cells[rowIndex, num], this.NumberFormat);
            //num++;
            //this.sheetSystemInfo.Cells[rowIndex, num] = hyduct.Rm;
            //if (HYDuctSystemExcelBook.<>o__42.<>p__4 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__42.<>p__4 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__42.<>p__4.Target(HYDuctSystemExcelBook.<>o__42.<>p__4, this.sheetSystemInfo.Cells[rowIndex, num], this.NumberFormat);
            //num++;
            //this.sheetSystemInfo.Cells[rowIndex, num] = hyduct.FrictionalResistance;
            //if (HYDuctSystemExcelBook.<>o__42.<>p__5 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__42.<>p__5 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__42.<>p__5.Target(HYDuctSystemExcelBook.<>o__42.<>p__5, this.sheetSystemInfo.Cells[rowIndex, num], this.NumberFormat);
            //num++;
            //this.sheetSystemInfo.Cells[rowIndex, num] = hyduct.Coefficient;
            //if (HYDuctSystemExcelBook.<>o__42.<>p__6 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__42.<>p__6 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__42.<>p__6.Target(HYDuctSystemExcelBook.<>o__42.<>p__6, this.sheetSystemInfo.Cells[rowIndex, num], this.NumberFormat);
            //num++;
            //this.sheetSystemInfo.Cells[rowIndex, num] = hyduct.ShockResistance;
            //if (HYDuctSystemExcelBook.<>o__42.<>p__7 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__42.<>p__7 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__42.<>p__7.Target(HYDuctSystemExcelBook.<>o__42.<>p__7, this.sheetSystemInfo.Cells[rowIndex, num], this.NumberFormat);
            //num++;
            //this.sheetSystemInfo.Cells[rowIndex, num] = hyduct.Resistance;
            //if (HYDuctSystemExcelBook.<>o__42.<>p__8 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__42.<>p__8 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__42.<>p__8.Target(HYDuctSystemExcelBook.<>o__42.<>p__8, this.sheetSystemInfo.Cells[rowIndex, num], this.NumberFormat);
			rowIndex++;
		}

		private void WriteResistanceCoefficient(ref int rowIndex)
		{
			int num = 1;
			int num2 = 0;
			this.WriteResCoeInfo(ref rowIndex, "编号", ref num);
			this.WriteResCoeInfo(ref rowIndex, "Revit序号", ref num);
			this.WriteResCoeInfo(ref rowIndex, "局阻阻力(Pa)", ref num);
			this.WriteDuctRC(ref rowIndex, num, ref num2, 1);
			num += num2;
			this.WriteResCoeInfo(ref rowIndex, "局阻系数", ref num);
			this.WriteDuctRC(ref rowIndex, num, ref num2, 0);
            Microsoft.Office.Interop.Excel.Range range;
			if (num2 > 1)
			{
				range = this.sheetCoefficient.get_Range(this.ToCellPosition(1, 1), this.ToCellPosition(rowIndex - 1, num + num2 - 1));
				this.AddBorderCoff(1, 1, rowIndex, num + num2 - 1);
				for (int i = 1; i <= num + num2 - 1; i++)
				{
					this.ColumnWidthAutoFitCoeff(i);
				}
			}
			else
			{
				range = this.sheetCoefficient.get_Range(this.ToCellPosition(1, 1), this.ToCellPosition(rowIndex - 1, num));
				this.AddBorderCoff(1, 1, rowIndex, num);
				for (int j = 1; j <= num; j++)
				{
					this.ColumnWidthAutoFitCoeff(j);
				}
			}
			range.Font.Name = "微软雅黑";
			range.Font.Size = 12;
			range.NumberFormatLocal = this.NumberFormat;
			range = this.sheetCoefficient.get_Range(this.ToCellPosition(1, 1), this.ToCellPosition(rowIndex - 1, 1));
			range.Font.Name = "微软雅黑";
			range.Font.Size = 12;
			range.NumberFormatLocal = this.NumberMark;
			int num3 = 1;
			if (num2 > 1)
			{
				this.WriteTextCoeff(ref num3, 1, num + num2 - 1, "鸿业风系统局阻明细表", true);
				this.MergeCellsCoeff(num3 - 1, 1, num + num2 - 1);
                //if (HYDuctSystemExcelBook.<>o__43.<>p__0 == null)
                //{
                //    HYDuctSystemExcelBook.<>o__43.<>p__0 = CallSite<Func<CallSite, object, XlHAlign, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "HorizontalAlignment", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                //    }));
                //}
                //HYDuctSystemExcelBook.<>o__43.<>p__0.Target(HYDuctSystemExcelBook.<>o__43.<>p__0, this.sheetCoefficient.Cells[1, 1], XlHAlign.xlHAlignCenter);
                //this.WriteTextCoeff(ref num3, 1, num + num2 - 1, this.DuctSystem.Name, true);
                //this.MergeCellsCoeff(num3 - 1, 1, num + num2 - 1);
                //if (HYDuctSystemExcelBook.<>o__43.<>p__1 == null)
                //{
                //    HYDuctSystemExcelBook.<>o__43.<>p__1 = CallSite<Func<CallSite, object, XlHAlign, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "HorizontalAlignment", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
                //    {
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                //    }));
                //}
                //HYDuctSystemExcelBook.<>o__43.<>p__1.Target(HYDuctSystemExcelBook.<>o__43.<>p__1, this.sheetCoefficient.Cells[2, 1], XlHAlign.xlHAlignCenter);
				return;
			}
			this.WriteTextCoeff(ref num3, 1, num, "鸿业风系统局阻明细表", true);
			this.MergeCellsCoeff(num3 - 1, 1, num);
            //if (HYDuctSystemExcelBook.<>o__43.<>p__2 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__43.<>p__2 = CallSite<Func<CallSite, object, XlHAlign, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "HorizontalAlignment", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__43.<>p__2.Target(HYDuctSystemExcelBook.<>o__43.<>p__2, this.sheetCoefficient.Cells[1, 1], XlHAlign.xlHAlignCenter);
            //this.WriteTextCoeff(ref num3, 1, num + num2 - 1, this.DuctSystem.Name, true);
            //this.MergeCellsCoeff(num3 - 1, 1, num);
            //if (HYDuctSystemExcelBook.<>o__43.<>p__3 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__43.<>p__3 = CallSite<Func<CallSite, object, XlHAlign, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "HorizontalAlignment", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
            //    {
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
            //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
            //    }));
            //}
            //HYDuctSystemExcelBook.<>o__43.<>p__3.Target(HYDuctSystemExcelBook.<>o__43.<>p__3, this.sheetCoefficient.Cells[2, 1], XlHAlign.xlHAlignCenter);
		}

		private void WriteResCoeInfo(ref int rowIndex, string headerName, ref int colIndex)
		{
			rowIndex = 3;
			if (headerName == "编号")
			{
				this.sheetCoefficient.Cells[rowIndex, colIndex] = headerName;
				rowIndex++;
				using (List<HYPipeline>.Enumerator enumerator = this.DuctSystem.Pipelines.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						HYPipeline hypipeline = enumerator.Current;
						this.sheetCoefficient.Cells[rowIndex, colIndex] = (hypipeline as HYDuctStraight).Index;
                        //if (HYDuctSystemExcelBook.<>o__44.<>p__0 == null)
                        //{
                        //    HYDuctSystemExcelBook.<>o__44.<>p__0 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
                        //    {
                        //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                        //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
                        //    }));
                        //}
                        //HYDuctSystemExcelBook.<>o__44.<>p__0.Target(HYDuctSystemExcelBook.<>o__44.<>p__0, this.sheetCoefficient.Cells[rowIndex, colIndex], this.NumberMark);
                        //this.MergeRowCells(rowIndex, colIndex, rowIndex + 1);
                        //if (HYDuctSystemExcelBook.<>o__44.<>p__1 == null)
                        //{
                        //    HYDuctSystemExcelBook.<>o__44.<>p__1 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
                        //    {
                        //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                        //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
                        //    }));
                        //}
                        //HYDuctSystemExcelBook.<>o__44.<>p__1.Target(HYDuctSystemExcelBook.<>o__44.<>p__1, this.sheetCoefficient.Cells[rowIndex, colIndex], this.NumberMark);
						rowIndex += 2;
					}
					goto IL_4AB;
				}
			}
			if (headerName == "Revit序号")
			{
				this.sheetCoefficient.Cells[rowIndex, colIndex] = headerName;
				rowIndex++;
				using (List<HYPipeline>.Enumerator enumerator = this.DuctSystem.Pipelines.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						HYPipeline hypipeline2 = enumerator.Current;
						this.sheetCoefficient.Cells[rowIndex, colIndex] = (hypipeline2 as HYDuctStraight).Number;
						this.MergeRowCells(rowIndex, colIndex, rowIndex + 1);
						rowIndex += 2;
					}
					goto IL_4AB;
				}
			}
			if (headerName == "局阻系数")
			{
				this.sheetCoefficient.Cells[rowIndex, colIndex] = headerName;
				rowIndex++;
				using (List<HYPipeline>.Enumerator enumerator = this.DuctSystem.Pipelines.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						HYPipeline hypipeline3 = enumerator.Current;
						this.sheetCoefficient.Cells[rowIndex, colIndex] = (hypipeline3 as HYDuctStraight).Coefficient;
						this.MergeRowCells(rowIndex, colIndex, rowIndex + 1);
                        //if (HYDuctSystemExcelBook.<>o__44.<>p__2 == null)
                        //{
                        //    HYDuctSystemExcelBook.<>o__44.<>p__2 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
                        //    {
                        //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                        //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
                        //    }));
                        //}
                        //HYDuctSystemExcelBook.<>o__44.<>p__2.Target(HYDuctSystemExcelBook.<>o__44.<>p__2, this.sheetCoefficient.Cells[rowIndex, colIndex], this.NumberFormatCoeff);
						rowIndex += 2;
					}
					goto IL_4AB;
				}
			}
			if (headerName == "局阻阻力(Pa)")
			{
				this.sheetCoefficient.Cells[rowIndex, colIndex] = headerName;
				rowIndex++;
				foreach (HYPipeline hypipeline4 in this.DuctSystem.Pipelines)
				{
					this.sheetCoefficient.Cells[rowIndex, colIndex] = (hypipeline4 as HYDuctStraight).ShockResistance;
					this.MergeRowCells(rowIndex, colIndex, rowIndex + 1);
                    //if (HYDuctSystemExcelBook.<>o__44.<>p__3 == null)
                    //{
                    //    HYDuctSystemExcelBook.<>o__44.<>p__3 = CallSite<Func<CallSite, object, string, object>>.Create(Binder.SetMember(CSharpBinderFlags.None, "NumberFormatlocal", typeof(HYDuctSystemExcelBook), new CSharpArgumentInfo[]
                    //    {
                    //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                    //        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
                    //    }));
                    //}
                    //HYDuctSystemExcelBook.<>o__44.<>p__3.Target(HYDuctSystemExcelBook.<>o__44.<>p__3, this.sheetCoefficient.Cells[rowIndex, colIndex], this.NumberFormatCoeff);
					rowIndex += 2;
				}
			}
			IL_4AB:
			colIndex++;
		}

		private void WriteDuctRC(ref int rowIndex, int coeCollIndex, ref int collNum, int mark = 0)
		{
			rowIndex = 4;
			collNum = 0;
			if (mark == 0)
			{
				using (List<HYPipeline>.Enumerator enumerator = this.DuctSystem.Pipelines.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						HYPipeline hypipeline = enumerator.Current;
						int num = coeCollIndex;
						int num2 = 0;
						List<HYPipeline.AttachObject> attachObjects = (hypipeline as HYDuctStraight).AttachObjects;
						if (attachObjects == null || attachObjects.Count <= 0)
						{
							rowIndex += 2;
						}
						else
						{
							foreach (HYPipeline.AttachObject attachObject in from ao in attachObjects
							where ao.Object is HYFitting
							select ao)
							{
								num2++;
								this.sheetCoefficient.Cells[rowIndex, num] = attachObject.ShowName;
								this.SetCellTectAlign(rowIndex, num);
								this.sheetCoefficient.Cells[rowIndex + 1, num] = StringTools.CutOffEfficacious(attachObject.Value.ToString(), 3);
								this.SetCellTectAlign(rowIndex + 1, num);
								num++;
							}
							if (collNum < num2)
							{
								collNum = num2;
							}
							rowIndex += 2;
						}
					}
					goto IL_28E;
				}
			}
			foreach (HYPipeline hypipeline2 in this.DuctSystem.Pipelines)
			{
				int num = coeCollIndex;
				int num3 = 0;
				List<HYPipeline.AttachObject> attachObjects2 = (hypipeline2 as HYDuctStraight).AttachObjects;
				if (attachObjects2 == null || attachObjects2.Count <= 0)
				{
					rowIndex += 2;
				}
				else
				{
					foreach (HYPipeline.AttachObject attachObject2 in from ao in attachObjects2
					where !(ao.Object is HYFitting)
					select ao)
					{
						num3++;
						this.sheetCoefficient.Cells[rowIndex + 1, num] = StringTools.CutOffEfficacious(attachObject2.Value.ToString(), 3) + "Pa";
						this.SetCellTectAlign(rowIndex + 1, num);
						this.sheetCoefficient.Cells[rowIndex, num] = attachObject2.ShowName;
						this.SetCellTectAlign(rowIndex, num);
						num++;
					}
					if (collNum < num3)
					{
						collNum = num3;
					}
					rowIndex += 2;
				}
			}
			IL_28E:
			if (collNum > 1)
			{
				if (mark == 0)
				{
					this.WriteHeaderText(3, coeCollIndex, coeCollIndex + collNum - 1, "局阻系数详细设置", true);
					return;
				}
				this.WriteHeaderText(3, coeCollIndex, coeCollIndex + collNum - 1, "局部阻力详细设置", true);
				return;
			}
			else
			{
				if (mark == 0)
				{
					this.WriteHeaderText(3, coeCollIndex, coeCollIndex, "局阻系数详细设置", true);
					return;
				}
				this.WriteHeaderText(3, coeCollIndex, coeCollIndex, "局部阻力详细设置", true);
				return;
			}
		}

		private void WriteHeaderText(int rowIndex, int startColumnIndex, int endColumnIndex, string text, bool HorizontalCenter = false)
		{
			this.sheetCoefficient.Cells[rowIndex, startColumnIndex] = text;
            Microsoft.Office.Interop.Excel.Range range = this.sheetCoefficient.get_Range(this.ToCellPosition(rowIndex, startColumnIndex), this.ToCellPosition(rowIndex, endColumnIndex));
			range.MergeCells = true;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			if (HorizontalCenter)
			{
				range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			}
			else
			{
				range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
			}
			rowIndex++;
		}

		private void SetTextAlign(int srIndex, int erIndex, int scIndex, int ecIndex, bool HorizontalCenter = true)
		{
            Microsoft.Office.Interop.Excel.Range range = this.sheetCoefficient.get_Range(this.ToCellPosition(srIndex, scIndex), this.ToCellPosition(erIndex, ecIndex));
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			if (HorizontalCenter)
			{
				range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
				return;
			}
			range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
		}

		private void SetCellTectAlign(int rowIndex, int collIndex)
		{
            //if (HYDuctSystemExcelBook.<>o__48.<>p__0 == null)
            //{
            //    HYDuctSystemExcelBook.<>o__48.<>p__0 = CallSite<Func<CallSite, object, Range>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Range), typeof(HYDuctSystemExcelBook)));
            //}
            //Range range = HYDuctSystemExcelBook.<>o__48.<>p__0.Target(HYDuctSystemExcelBook.<>o__48.<>p__0, this.sheetCoefficient.Cells[rowIndex, collIndex]);
            //range.VerticalAlignment = XlVAlign.xlVAlignCenter;
            //range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
		}

		private Application excelApplication;

		private Workbook workbook;

		private Worksheet sheetSystemInfo;

		private Worksheet sheetCoefficient;

		private HYDuctSystem m_DuctSystem;

		private List<ColumnInfo> GridColumns;

		private int ColumnCount = 12;

		private string NumberFormat = "0.00";

		private string NumberMark = "0";

		private string NumberFormatCoeff = "0.000";

		private BackgroundWorker m_BkWorker;

		private int rate;
	}
}
